# -*- coding:utf-8 -*-
# 全局变量--start
from spider.chapter02.getData import getData
from spider.chapter03.getText import getText
from saveDataToExcel import saveDataToExcel
from saveDataToSQlite import saveDataToSQlite

baseurl = 'https://movie.douban.com/top250?start='

def main():
    # 1.获取网页数据
    htmllist = getData(baseurl, 1, 25)
    # 2.解析网页数据
    datalist=getText(htmllist)
    print(datalist)
    # 3.保存数据
    # 保存到Excel表格
    excelpath='../../豆瓣电影Top250.xls'
    saveDataToExcel(datalist,excelpath)

    # 保存到SQLite数据库
    # 指定数据库文件的路径
    dbpath='../../movie.db'
    saveDataToSQlite(datalist,dbpath)

if __name__ == '__main__':
    main()
